package com.bookstore.dao.impl;

import com.bookstore.dao.BaseDao;
import com.bookstore.dao.NoticeDao;
import com.bookstore.entity.Notice;
import com.bookstore.entity.User;

import java.util.List;

public class NoticeDaoImpl extends BaseDao implements NoticeDao {
    @Override
    public int insertNotice(Notice notice) {
        String sql="insert into t_notice(title,details,notice_time) values(?,?,?)";
        return super.update(sql,notice.getTitle(),notice.getDetails(),notice.getNotice_time());
    }

    @Override
    public int updateNotice(Notice notice) {
        String sql="update t_notice title=?,details=?,notice_time=? where notice_id=?";
        return super.update(sql,notice.getTitle(),notice.getDetails(),notice.getNotice_time(),notice.getNotice_id());
    }

    @Override
    public int deleteNotice(Long noticeId) {
        String sql="delete from t_notice where notice_id=?";
        return super.update(sql,noticeId);
    }

    @Override
    public List<Notice> queryAllNotice() {
        String sql="select * from t_notice";
        return super.queryMore(Notice.class,sql);
    }

    @Override
    public Notice queryNoticeId(Long noticeId) {
        String sql="select * from t_notice where notice_id=?";
        return super.queryOne(Notice.class,sql,noticeId);
    }
}
